import { request } from './index'
import type { LoginRequest, RegisterRequest, LoginResponse, User } from '@/types'

export const authApi = {
  // 用户登录
  login(data: LoginRequest): Promise<LoginResponse> {
    return request.post('/auth/login', data)
  },

  // 用户注册
  register(data: RegisterRequest): Promise<LoginResponse> {
    return request.post('/auth/register', data)
  },

  // 获取当前用户信息
  getCurrentUser(): Promise<User> {
    return request.get('/auth/me')
  },

  // 刷新token
  refreshToken(): Promise<{ token: string }> {
    return request.post('/auth/refresh')
  },

  // 登出
  logout(): Promise<void> {
    return request.post('/auth/logout')
  }
}